﻿using Microsoft.ExtendedReflection.Monitoring;
using Microsoft.VisualStudio.TestTools.Common;
using Microsoft.VisualStudio.TestTools.Execution;

namespace MolesVS2012.Host.Host
{
    internal sealed class SafeResultSink : IResultSink
    {
        private readonly IResultSink sink;

        public SafeResultSink(IResultSink sink)
        {
            this.sink = sink;
        }

        public void AddResult(TestMessage testMessage)
        {
            using (_ProtectingThreadContext.Acquire())
                this.sink.AddResult(testMessage);
        }
    }
}
